﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace DrivingCRM.Views.Private.CRM
{
    public partial class ListClients : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["User"] != null)
            {
                if ((Session["User"] as List<string>)[0] == "Salesman" ||
                    (Session["User"] as List<string>)[0] == "Stakeholder" ||
                    (Session["User"] as List<string>)[0] == "Client")
                {
                    this.DS_Agencies.Where = "it.IdAgency == @CurrentAgency";
                    this.DS_Agencies.WhereParameters.Add(new Parameter() { DbType = System.Data.DbType.Int32, Name = "CurrentAgency", DefaultValue = (Session["User"] as List<string>)[2] });
                    this.DDL_Agencies.Enabled = false;
                }
                else
                {
                    this.DDL_Agencies.Enabled = true;
                }
            }
            else
            {
                Response.Redirect("~/Views/Login.aspx");
            }
        }

        /// <summary>
        /// Méthode appelée au clic sur bouton d'ajout d'un utilisateur
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void B_AddUser_Click(object sender, EventArgs e)
        {
            Response.Redirect("~/Views/Private/CRM/AddUser.aspx");
        }
    }
}